﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataAccess_Layer;
using Business_Layer;

public partial class NNC_H_Default2 : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["NCC_UN"] == null)
        {
            Response.Redirect("Error.aspx");          
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        DateTime time = DateTime.Now;
        TinTucNCC x = new TinTucNCC();
        TinTucNCC_BUS bus = new TinTucNCC_BUS();
        
        x.TieuDe = TextBox1.Text;
        x.NoiDung = TextBox2.Text;
        x.NgayDangTin =Convert.ToDateTime( time.ToShortDateString());
        string m = "";
        if (FileUpload1.HasFile)
        {
                string filename = "NNC_H/TinTuc/" + FileUpload1.FileName;
                FileUpload1.SaveAs(Server.MapPath("~/") + filename);
                m = "~/" + filename;
                x.Hinh = m;         
        }
        x.TenNCC = Session["NCC_UN"].ToString();
        bus.Insert(x);
        Session["post"] = 1;
        Response.Redirect("ListNews.aspx");
        
        
    }
}